RAIS  3.2
C:/Projekte/RAIS/Specific Masks/CustomQueryRaisCustomization.aspx.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections;
00030 using System.Configuration;
00031 using System.Data;
00032 using System.Linq;
00033 using System.Web;
00034 using System.Web.Security;
00035 using System.Web.UI;
00036 using System.Web.UI.HtmlControls;
00037 using System.Web.UI.WebControls;
00038 using System.Web.UI.WebControls.WebParts;
00039 using System.Xml.Linq;
00040 
00041 using RAIS.Common.DynamicMaskManagement;
00042 using RAIS.Common.TableManagement;
00043 using RAIS.Common.UserManagement;
00044 using RAIS.UI.Common;
00045 
00046 using Queries = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Query>;
00047 using QueryParameters = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.QueryParameter>;
00048 using QueryParameterTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.QueryParameter.QueryParameterTypeData>;
00049 using Tables = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Table>;
00050 using CustomizationTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Query.CustomizationType>;
00051 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>;
00052 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>;
00053 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>;
00054 using DynamicMasks = System.Collections.Generic.Dictionary<string, RAIS.Common.DynamicMaskManagement.DynamicMask>;
00055 using ConsistencyChecks = System.Collections.Generic.Dictionary<string, RAIS.Common.DynamicMaskManagement.ConsistencyCheck>;
00056 using RecordTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.DynamicMaskManagement.ConsistencyCheck.RecordTypeData>;
00057 using Fields = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Field>;
00058 
00059 namespace RAIS.UI.SpecificMasks
00060 {
00064         public partial class CustomQueryRaisCustomization : System.Web.UI.Page
00065         {
00066                 //*********************************************************************
00067                 #region Enums
00068 
00071         enum CustomQuery_PageMode
00072                 {
00073                         view,
00074                         add,
00075                         edit
00076                 };
00077                 #endregion Enums
00078                 //*********************************************************************
00079                 #region Properties
00080 
00083                 protected UserData CurrentUser
00084                 {
00085                         get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00086                 }
00090                 CustomQuery_PageMode CurrentCustomQuery_PageMode
00091                 {
00092                         get
00093                         {
00094                                 if (this.Session[UI.Common.Constants.CUSTOM_QUERY_PARAMETERS_EDIT_MODE_TAG] != null)
00095                                 {
00096                                         return (CustomQuery_PageMode)this.Session[UI.Common.Constants.CUSTOM_QUERY_PARAMETERS_EDIT_MODE_TAG];
00097                                 }
00098                                 else
00099                                         return CustomQuery_PageMode.view;
00100                         }
00101                         set
00102                         {
00103                                 this.Session[UI.Common.Constants.CUSTOM_QUERY_PARAMETERS_EDIT_MODE_TAG] = value;
00104                                 this.SetControlsProperties();
00105                         }
00106                 }
00110                 bool EditMode
00111                 {
00112                         get 
00113                         {
00114                                 return this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.edit
00115                                         || this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add;
00116                         }
00117                 }
00121                 private RAIS.Common.TableManagement.Query.CustomizationType SelectedCustomizationType
00122                 {
00123                         get
00124                         {
00125                                 CustomizationTypes types = RAIS.ApplicationLogicLayer.TableManagement.GetCustomizationTypes();
00126                                 return types[this.DDLcustomizationType.SelectedValue];
00127                         }
00128                 }
00132                 private FunctionRole.Category SelectedCategory
00133                 {
00134                         get
00135                         {
00136                                 //FunctionRoleCategories categories = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoleCategories;
00137                                 FunctionRoleCategories categories = UI.Common.TableManagement.GetFunctionRoleCategories(this, false);
00138                                 if (categories != null && categories.ContainsKey(this.DDLcategory.SelectedValue))
00139                                         return categories[this.DDLcategory.SelectedValue];
00140                                 else
00141                                         return null;
00142                         }
00143                 }
00147                 private FunctionRole.Subcategory SelectedSubcategory
00148                 {
00149                         get
00150                         {
00151                                 if (this.SelectedCategory != null)
00152                                 {
00153                                         //FunctionRoleSubcategories subcategories = RAIS.ApplicationLogicLayer.UserManagement.GetFunctionalRoleSubcategories(this.SelectedCategory, false, false);
00154                                         FunctionRoleSubcategories subcategories = UI.Common.TableManagement.GetFunctionRoleSubcategoriesByCategory(this, this.SelectedCategory, false, false, false);
00155                                         if (subcategories != null && subcategories.ContainsKey(this.DDLsubcategory.SelectedValue))
00156                                                 return subcategories[this.DDLsubcategory.SelectedValue];
00157                                         else
00158                                                 return null;
00159                                 }
00160                                 else
00161                                         return null;
00162                         }
00163                 }
00167                 private Mask SelectedMask
00168                 {
00169                         get
00170                         {
00171                                 if (this.SelectedCategory != null && this.SelectedSubcategory != null)
00172                                 {
00173                                         //Masks masks = RAIS.ApplicationLogicLayer.UserManagement.GetMasks(this.SelectedCategory, this.SelectedSubcategory);
00174                                         Masks masks = UI.Common.TableManagement.GetMasksByCategoryAndSubcategory(this, this.SelectedCategory, this.SelectedSubcategory, false);
00175                                         if (masks != null && masks.ContainsKey(this.DDLmask.SelectedValue))
00176                                                 return masks[this.DDLmask.SelectedValue];
00177                                         else
00178                                                 return null;
00179                                 }
00180                                 else
00181                                         return null;
00182                         }
00183                 }
00187                 private DynamicMask SelectedDynamicMask
00188                 {
00189                         get
00190                         {
00191                                 if (this.SelectedMask != null)
00192                                 {
00193                                         //DynamicMasks dynamicMasks = RAIS.ApplicationLogicLayer.DynamicMaskManagement.GetDynamicMasksByMask(this.SelectedMask);
00194                                         DynamicMasks dynamicMasks = UI.Common.TableManagement.GetDynamicMasksByMask(this, this.SelectedMask, false);
00195                                         if (dynamicMasks != null && dynamicMasks.ContainsKey(this.DDLdynamicMask.SelectedValue))
00196                                                 return dynamicMasks[this.DDLdynamicMask.SelectedValue];
00197                                         else
00198                                                 return null;
00199                                 }
00200                                 else
00201                                         return null;
00202                         }
00203                 }
00207                 private ConsistencyCheck SelectedConsistencyCheck
00208                 {
00209                         get
00210                         {
00211                                 if (this.SelectedDynamicMask != null
00212                                                 && this.DDLconsistencyCheck.SelectedValue != string.Empty
00213                                         )
00214                                 {
00215                                         ConsistencyChecks consistencyChecks = UI.Common.DynamicMaskManagement.GetConsistencyChecksByDynamicMask(this, this.SelectedDynamicMask, false);
00216                                         if (consistencyChecks != null && consistencyChecks.ContainsKey(this.DDLconsistencyCheck.SelectedValue))
00217                                                 return consistencyChecks[this.DDLconsistencyCheck.SelectedValue];
00218                                         else
00219                                                 return null;
00220                                 }
00221                                 else
00222                                         return null;
00223                         }
00224                 }
00228                 private RAIS.Common.TableManagement.Query SelectedQuery
00229                 {
00230                         get
00231                         {
00232                                 Queries queries = RAIS.ApplicationLogicLayer.TableManagement.GetQueriesByCustomizationType(this.SelectedCustomizationType);
00233                                 if (queries != null && queries.ContainsKey(this.DDLcustomQuery.SelectedValue))
00234                                         return queries[this.DDLcustomQuery.SelectedValue];
00235                                 else
00236                                         return null;
00237                         }
00238                 }
00242                 private ConsistencyCheck.RecordTypeData SelectedRecordTypeData
00243                 {
00244                         get
00245                         {
00246                                 if (this.SelectedConsistencyCheck != null)
00247                                 {
00248                                         RecordTypes recordTypes = UI.Common.DynamicMaskManagement.GetRecordTypes(this, false);
00249                                         if (recordTypes != null && recordTypes.ContainsKey(this.DDLrecordType.SelectedValue))
00250                                                 return recordTypes[this.DDLrecordType.SelectedValue];
00251                                         else
00252                                                 return null;
00253                                 }
00254                                 else
00255                                         return null;
00256                         }
00257                 }
00261                 private Field SelectedField
00262                 {
00263                         get
00264                         {
00265                                 if (this.SelectedDynamicMask != null)
00266                                 {
00267                                         Fields fields = UI.Common.TableManagement.GetFieldsByDynamicMask(this, this.SelectedDynamicMask, this.SelectedCustomizationType, false);
00268                                         if (fields != null && fields.ContainsKey(this.DDLfield.SelectedValue))
00269                                                 return fields[this.DDLfield.SelectedValue];
00270                                         else
00271                                                 return null;
00272                                 }
00273                                 else
00274                                         return null;
00275                         }
00276                 }
00280                 protected bool ShowProtectors
00281                 {
00282                         get
00283                         {
00284                                 return UI.Common.PageManagement.GetShowProtectors(this);
00285                         }
00286                 }
00290                 protected bool ShowEvaluators
00291                 {
00292                         get
00293                         {
00294                                 return UI.Common.PageManagement.GetShowEvaluators(this);
00295                         }
00296                 }
00297                 #endregion
00298                 //*********************************************************************
00299                 #region Event handlers
00300         protected void Page_PreLoad(object sender, EventArgs e)
00301         {
00302             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00303         }
00310                 protected void Page_Load(object sender, EventArgs e)
00311                 {
00312                         this.Response.Cache.SetNoStore();
00313                         if (this.CurrentUser == null)
00314                                 UI.Common.AccessManagement.SignOut(this);
00315                         this.LBLresult.Text = string.Empty;
00316 
00317                         if (!this.IsPostBack)
00318                         {
00319                 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name;
00320                 this.LBLadmin.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00321                                 this.InitializeCustomizationType(string.Empty);
00322 
00323                                 UI.Common.PageManagement.InitializePage(this, this.TreeView1);
00324 //                              this.LBTNmessagebox.Visible = !(this.CurrentUser.FunctionalRole.Type == FunctionRole.FunctionRoleType.Guest);
00325                         }
00326             UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault);
00327                 }
00334                 protected void LNKqueryParameters_Click(object sender, EventArgs e)
00335                 {
00336                         this.Response.Redirect("~/CustomQueryParameters.aspx");
00337                 }
00344         protected void DDLcustomizationType_SelectedIndexChanged(object sender, EventArgs e)
00345         {
00346             this.OnSetCustomizationType();
00347             this.SetControlsProperties();
00348         }
00355                 protected void DDLcategory_SelectedIndexChanged(object sender, EventArgs e)
00356                 {
00357                         this.OnSetCategoryValue();
00358                         this.SetControlsProperties();
00359                 }
00366                 protected void DDLsubcategory_SelectedIndexChanged(object sender, EventArgs e)
00367                 {
00368                         this.OnSetSubcategoryValue();
00369                         this.SetControlsProperties();
00370                 }
00377                 protected void DDLmask_SelectedIndexChanged(object sender, EventArgs e)
00378                 {
00379                         this.OnSetMaskValue();
00380                         this.SetControlsProperties();
00381                 }
00388                 protected void DDLdynamicMask_SelectedIndexChanged(object sender, EventArgs e)
00389                 {
00390                         this.OnSetDynamicMaskValue();
00391                         this.SetControlsProperties();
00392                 }
00399                 protected void DDLfield_SelectedIndexChanged(object sender, EventArgs e)
00400                 {
00401                         this.OnSetFieldValue();
00402                         this.SetControlsProperties();
00403                 }
00410                 protected void DDLconsistencyCheck_SelectedIndexChanged(object sender, EventArgs e)
00411                 {
00412             this.OnSetConsistencyCheckValue();
00413                         this.SetControlsProperties();
00414                 }
00421                 protected void DDLcustomQuery_SelectedIndexChanged(object sender, EventArgs e)
00422                 {
00423                         this.OnSetCustomQueryValue();
00424                         this.SetControlsProperties();
00425                 }
00432                 protected void BTNadd_Click(object sender, EventArgs e)
00433                 {
00434                         this.CurrentCustomQuery_PageMode = CustomQuery_PageMode.add;
00435                         this.TXTnewMaskName.Text = string.Empty;
00436                         this.TXTnewDynamicMaskName.Text = string.Empty;
00437                         this.TXTgrouping.Text = string.Empty;
00438                         this.TXTwidths.Text = string.Empty;
00439                         this.TXTfooter.Text = string.Empty;
00440 
00441                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
00442                         {
00443                                 UI.Common.TableManagement.InitializeCustomQueryListByCustomizationType(
00444                                           this.DDLcustomQuery
00445                                         , this.SelectedCustomizationType
00446                                         , string.Empty);
00447                                 this.OnSetCustomQueryValue();
00448                                 //this.TXTnewConsistencyCheckName.Text = string.Empty;
00449                                 this.TXTconsistencyCheckMessage.Text = string.Empty;
00450                                 // Create new ConsistencyCheck to get default RecordType value
00451                                 ConsistencyCheck consistencyCheck = new ConsistencyCheck();
00452                                 this.DDLrecordType.SelectedValue = consistencyCheck.TypeText;
00453                         }
00454                 }
00461                 protected void BTNedit_Click(object sender, EventArgs e)
00462                 {
00463                         this.CurrentCustomQuery_PageMode = CustomQuery_PageMode.edit;
00464                 }
00471                 protected void BTNdelete_Click(object sender, EventArgs e)
00472                 {
00473                         bool success = false;
00474                         string returnMessage = string.Empty;
00475 
00476                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
00477                         {
00478                                 ConsistencyCheck consistencyCheck = this.SelectedConsistencyCheck;
00479                                 success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.RemoveConsistencyCheck(consistencyCheck, ref returnMessage);
00480                                 if (success)
00481                                 {
00482                                         OnSetDynamicMaskValue();
00483                                 }
00484                         }
00485                         else
00486                         {
00487                                 DynamicMask dynamicMask = this.SelectedDynamicMask;
00488                                 success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.RemoveDynamicMask(dynamicMask, ref returnMessage);
00489                                 if (success)
00490                                 {
00491                                         OnSetSubcategoryValue();
00492                                 }
00493                         }
00494 
00495                         if (success)
00496                         {
00497                                 this.CurrentCustomQuery_PageMode = CustomQuery_PageMode.view;
00498                                 this.SetControlsProperties();
00499                         }
00500 
00501                         RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00502                                                                                                                                 returnMessage,
00503                                                                                                                                 success);
00504                 }
00511                 protected void BTNdiscard_Click(object sender, EventArgs e)
00512                 {
00513                         this.CurrentCustomQuery_PageMode = CustomQuery_PageMode.view;
00514                         this.OnSetDynamicMaskValue();
00515                         this.SetControlsProperties();
00516                 }
00523                 protected void BTNapply_Click(object sender, EventArgs e)
00524                 {
00525                         bool success = true;
00526                         string returnMessage = string.Empty;
00527 
00528                         // Validate query parameters
00529                         success = RAIS.ApplicationLogicLayer.TableManagement.ValidateQueryParameters(this.SelectedQuery, ref returnMessage);
00530 
00531                         if (success)
00532                         {
00533                                 // Create query
00534                                 success = RAIS.ApplicationLogicLayer.TableManagement.CreateQuery(this.SelectedQuery, ref returnMessage);
00535 
00536                                 if (success)
00537                                 {
00538                                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ListWithFilter
00539                                                         || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
00540                                                         || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport
00541                                                 )
00542                                         {
00543                                                 if ((this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
00544                                                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
00545                                                         && this.SelectedQuery == null)
00546                                                 {
00547                                                         success = false;
00548                                                         returnMessage = "Choose custom query";
00549                                                 }
00550                                                 else
00551                                                 {
00552                                                         // Get dynamic mask properties from controls
00553                                                         DynamicMask dynamicMask = GetDynamicMaskCustomizationParametersFromControls();
00554                                                         dynamicMask.SetNewQuery(this.SelectedQuery);
00555 
00556                                                         if (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add)
00557                                                         {
00558                                                                 success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.AddDynamicMask(
00559                                                                           this.SelectedSubcategory.ID
00560                                                                         , this.TXTnewMaskName.Text
00561                                                                         , dynamicMask
00562                                                                         , ref returnMessage
00563                                                                 );
00564 
00565                                                                 if (success)
00566                                                                 {
00567                                                                         OnSetSubcategoryValue();
00568                                                                         this.DDLmask.SelectedValue = this.TXTnewMaskName.Text;
00569                                                                         OnSetMaskValue();
00570                                                                         this.DDLdynamicMask.SelectedValue = this.TXTnewDynamicMaskName.Text;
00571                                                                 }
00572                                                         }
00573                                                         else
00574                                                         {
00575                                                                 success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.SaveDynamicMask(dynamicMask, ref returnMessage);
00576                                                         }
00577                                                         if (success)
00578                                                                 this.OnSetDynamicMaskValue();
00579                                                 }
00580                                         }
00581 
00582                                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
00583                                         {
00584                                                 if (this.DDLrecordType.SelectedValue != "0")
00585                                                 {
00586                                                         ConsistencyCheck consistencyCheck = GetConsistencyCheckCustomizationParametersFromControls();
00587                                                         if (!string.IsNullOrEmpty(consistencyCheck.QueryName))
00588                                                         {
00589                                                                 if (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add)
00590                                                                         success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.AddConsistencyCheck(this.SelectedDynamicMask, consistencyCheck, ref returnMessage);
00591                                                                 else
00592                                                                         success = RAIS.ApplicationLogicLayer.DynamicMaskManagement.SaveConsistencyCheck(consistencyCheck, ref returnMessage);
00593 
00594                                                                 if (success)
00595                                                                 {
00596                                                                         OnSetDynamicMaskValue();
00597                                                                         this.DDLconsistencyCheck.SelectedValue = consistencyCheck.Name;
00598                                                                         OnSetConsistencyCheckValue();
00599                                                                 }
00600                                                         }
00601                                                         else
00602                                                         {
00603                                                                 success = false;
00604                                                                 returnMessage = "Choose custom query";
00605                                                         }
00606                                                 }
00607                                                 else
00608                                                 {
00609                                                         success = false;
00610                                                         returnMessage = "Choose consistency check type";
00611                                                 }
00612                                         }
00613 
00614                     if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.EntryFilter
00615                         || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.RanAutogeneration)
00616                     {
00617                         Field field = this.SelectedField;
00618                         field.QueryName = (this.SelectedQuery != null)
00619                             ? this.SelectedQuery.QueryNameWithParameters
00620                             : string.Empty;
00621 
00622                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.RanAutogeneration && this.SelectedQuery != null)
00623                             field.QueryName = this.SelectedQuery.Name;
00624 
00625                         success = RAIS.ApplicationLogicLayer.TableManagement.SaveFieldQueryName(field, ref returnMessage);
00626 
00627                         if (success)
00628                         {
00629                             OnSetFieldValue();
00630                         }
00631                     }
00632 
00633                                         if (success)
00634                                         {
00635                                                 // Set form into view mode
00636                                                 this.CurrentCustomQuery_PageMode = CustomQuery_PageMode.view;
00637                                                 this.SetControlsProperties();
00638                                         }
00639                                 }
00640                         }
00641                         RAIS.UI.Common.MessageDisplay.DisplayReturnMessage(this.LBLresult,
00642                                                                                                                                 returnMessage,
00643                                                                                                                                 success);
00644                 }
00651                 protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
00652                 {
00653                         UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1);
00654                 }
00661                 protected void LBTNlogout_Click(object sender, EventArgs e)
00662                 {
00663                         UI.Common.AccessManagement.SignOut(this);
00664                 }
00665                 #endregion
00666                 //*********************************************************************
00667                 #region Private helper methods
00668 
00669                 private void InitializeCustomizationType(string selection)
00670                 {
00671                         UI.Common.TableManagement.InitializeCustomizationTypeList(this.DDLcustomizationType, selection);
00672             DDLcustomizationType.Items.Insert(0, "");
00673             DDLcustomizationType.SelectedIndex = 0;
00674                         //this.OnSetCustomizationType();
00675                         this.SetControlsProperties();
00676                 }
00680                 private void OnSetCustomizationType()
00681                 {
00682             if (DDLcustomizationType.SelectedValue != "")
00683             {
00684                 this.BTNdelete.Attributes.Add("onclick"
00685                     , string.Format("javascript: return confirm('{0}');", GetDeleteQuestion().Replace("'", "\\'")));
00686 
00687                 UI.Common.TableManagement.InitializeCategoriesListByCustomizationType(
00688                       this.DDLcategory
00689                     , this.SelectedCustomizationType);
00690                 this.OnSetCategoryValue();
00691             }
00692                         this.SetControlsProperties();
00693                 }
00697                 private void OnSetCategoryValue()
00698                 {
00699                         UI.Common.TableManagement.InitializeSubcategoryListByCategory(
00700                               this.DDLsubcategory
00701                             , this.SelectedCategory
00702                                 , this.ShowProtectors
00703                                 , this.ShowEvaluators);
00704                         this.OnSetSubcategoryValue();
00705                         this.SetControlsProperties();
00706                 }
00710                 private void OnSetSubcategoryValue()
00711                 {
00712                         UI.Common.TableManagement.InitializeMaskListByCategoryAndSubcategory(
00713                               this.DDLmask
00714                             , this.SelectedCategory
00715                                 , this.SelectedSubcategory);
00716                         this.OnSetMaskValue();
00717                         this.SetControlsProperties();
00718                 }
00722                 private void OnSetMaskValue()
00723                 {
00724                         UI.Common.TableManagement.InitializeDynamicMaskListByMaskAndCustomizationType(
00725                               this.DDLdynamicMask
00726                             , this.SelectedMask
00727                                 , this.SelectedCustomizationType);
00728                         this.OnSetDynamicMaskValue();
00729                         this.SetControlsProperties();
00730                 }
00734                 private void OnSetDynamicMaskValue()
00735                 {
00736                         if (this.SelectedDynamicMask != null)
00737                         {
00738                                 if (this.SelectedDynamicMask.Type == DynamicMask.DynamicMaskType.ReportMask)
00739                                 {
00740                                         this.TXTgrouping.Text = this.SelectedDynamicMask.Grouping;
00741                                         this.TXTwidths.Text = this.SelectedDynamicMask.Widths;
00742                                         this.TXTfooter.Text = this.SelectedDynamicMask.Footer;
00743                                 }
00744 
00745                                 if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
00746                                 {
00747                                         UI.Common.DynamicMaskManagement.InitializeConsistencyCheckListByDynamicMask(
00748                                                   this.DDLconsistencyCheck
00749                                                 , this.SelectedDynamicMask);
00750                                         this.OnSetConsistencyCheckValue();
00751                                 }
00752                                 else if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.EntryFilter
00753                                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.RanAutogeneration
00754                                         )
00755                                 {
00756                                         UI.Common.TableManagement.InitializeFieldListByDynamicMaskAndCustomizationType(
00757                                                   this.DDLfield
00758                                                 , this.SelectedDynamicMask
00759                                                 , this.SelectedCustomizationType);
00760                                         this.OnSetFieldValue();
00761                                 }
00762                                 else
00763                                 {
00764                                         UI.Common.TableManagement.InitializeCustomQueryListByCustomizationType(
00765                                                   this.DDLcustomQuery
00766                                                 , this.SelectedCustomizationType
00767                                                 , this.SelectedDynamicMask.QueryName);
00768                                         this.OnSetCustomQueryValue();
00769                                 }
00770                                 this.SetControlsProperties();
00771                         }
00772                 }
00776                 private void OnSetFieldValue()
00777                 {
00778                         if (this.SelectedField != null)
00779                         {
00780                                 UI.Common.TableManagement.InitializeCustomQueryListByCustomizationType(
00781                                           this.DDLcustomQuery
00782                                         , this.SelectedCustomizationType
00783                                         , this.SelectedField.QueryNameWithoutParameters);
00784                                 this.OnSetCustomQueryValue();
00785                                 this.SetControlsProperties();
00786                         }
00787                 }
00791                 private void OnSetConsistencyCheckValue()
00792                 {
00793                         UI.Common.TableManagement.InitializeCustomQueryListByCustomizationType(
00794                                   this.DDLcustomQuery
00795                                 , this.SelectedCustomizationType
00796                                 , (this.SelectedConsistencyCheck == null) 
00797                                         ? string.Empty 
00798                                         : this.SelectedConsistencyCheck.Name);
00799                         this.OnSetCustomQueryValue();
00800 
00801                         TXTconsistencyCheckMessage.Text = (this.SelectedConsistencyCheck == null)
00802                                 ? string.Empty
00803                                 : this.SelectedConsistencyCheck.Message;
00804 
00805                         UI.Common.DynamicMaskManagement.InitializeRecordTypesList(
00806                                   this.DDLrecordType
00807                                 , (this.SelectedConsistencyCheck == null)
00808                                         ? string.Empty
00809                                         : this.SelectedConsistencyCheck.TypeData.VisibleName);
00810 
00811                         this.SetControlsProperties();
00812                 }
00816                 private void OnSetCustomQueryValue()
00817                 {
00818                         if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
00819                         {
00820                                 if (this.SelectedQuery != null)
00821                                         TXTnewConsistencyCheckName.Text = this.SelectedQuery.Name;
00822                                 else
00823                                         TXTnewConsistencyCheckName.Text = string.Empty;
00824                         }
00825                 }
00829                 private void SetControlsProperties()
00830                 {
00831             this.DDLcustomizationType.Enabled = !this.EditMode;
00832                         this.LBLcustomizationType.Enabled = this.DDLcustomizationType.Enabled;
00833 
00834             if (HideIfEmptyType())
00835                 return;
00836 
00837                         this.DDLcategory.Enabled = !this.EditMode
00838                                 && (this.SelectedCustomizationType != RAIS.Common.TableManagement.Query.CustomizationType.QueryReport)
00839                                 && (this.SelectedCustomizationType != RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport);
00840                         this.LBLcategory.Enabled = this.DDLcategory.Enabled;
00841                         
00842             this.DDLsubcategory.Enabled = !this.EditMode;
00843                         this.LBLsubcategory.Enabled = this.DDLsubcategory.Enabled;
00844 
00845                         this.DDLmask.Enabled = !this.EditMode;
00846                         this.LBLmask.Enabled = this.DDLmask.Enabled;
00847                         
00848             this.DDLdynamicMask.Enabled = !this.EditMode;
00849                         this.LBLdynamicMask.Enabled = this.DDLdynamicMask.Enabled;
00850 
00851                         this.TXTnewMaskName.Visible = (this.SelectedCategory != null)
00852                 && (this.SelectedCategory.Name == "Query" || this.SelectedCategory.Name == "Statistics")
00853                                 && (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add);
00854                         this.LBLnewMaskName.Visible = this.TXTnewMaskName.Visible;
00855                         this.RFVnewMaskName.Visible = this.TXTnewMaskName.Visible;
00856                         this.RFVnewMaskName.Enabled = this.TXTnewMaskName.Visible;
00857 
00858             this.TXTnewDynamicMaskName.Visible = (this.SelectedCategory != null)
00859                 && (this.SelectedCategory.Name == "Query" || this.SelectedCategory.Name == "Statistics")
00860                                 && (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add);
00861                         this.LBLnewDynamicMaskName.Visible = this.TXTnewDynamicMaskName.Visible;
00862                         this.RFVnewDynamicMaskName.Visible = this.TXTnewDynamicMaskName.Visible;
00863                         this.RFVnewDynamicMaskName.Enabled = this.TXTnewDynamicMaskName.Visible;
00864 
00865                         this.DDLmask.Visible = !this.TXTnewMaskName.Visible;
00866                         this.LBLmask.Visible = this.DDLmask.Visible;
00867                         
00868             this.DDLdynamicMask.Visible = !this.TXTnewDynamicMaskName.Visible;
00869                         this.LBLdynamicMask.Visible = this.DDLdynamicMask.Visible;
00870 
00871                         TXTnewConsistencyCheckName.Visible = this.EditMode
00872                                 && (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck);
00873                         LBLnewConsistencyCheckName.Visible = TXTnewConsistencyCheckName.Visible;
00874                         TXTnewConsistencyCheckName.Enabled = false;
00875                         LBLnewConsistencyCheckName.Enabled = false;
00876 
00877                         this.DDLfield.Visible = (
00878                                         this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.EntryFilter
00879                                         || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.RanAutogeneration
00880                                 );
00881                         this.LBLfield.Visible = this.DDLfield.Visible;
00882                         this.DDLfield.Enabled = !this.EditMode;
00883                         this.LBLfield.Enabled = this.DDLfield.Enabled;
00884 
00885                         this.DDLcustomQuery.AutoPostBack =
00886                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck);
00887                         this.DDLconsistencyCheck.Visible = !TXTnewConsistencyCheckName.Visible
00888                                 && (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck);
00889                         this.LBLconsistencyCheck.Visible = this.DDLconsistencyCheck.Visible;
00890 
00891                         this.DDLcustomQuery.Enabled = this.EditMode;
00892                         this.LBLcustomQuery.Enabled = this.DDLcustomQuery.Enabled;
00893                         foreach (Control control in this.PNLcontrols.Controls)
00894                                 if (control is BaseValidator)
00895                                         ((BaseValidator)control).Enabled = this.EditMode;
00896 
00897                         this.TXTgrouping.Visible = (this.SelectedDynamicMask != null)
00898                                 && (this.SelectedDynamicMask.Type == DynamicMask.DynamicMaskType.ReportMask);
00899                         this.LBLgrouping.Visible = this.TXTgrouping.Visible;
00900                         this.TXTgrouping.Enabled = this.EditMode;
00901                         this.LBLgrouping.Enabled = this.TXTgrouping.Enabled;
00902 
00903                         this.TXTwidths.Visible = (this.SelectedDynamicMask != null)
00904                                 && (this.SelectedDynamicMask.Type == DynamicMask.DynamicMaskType.ReportMask);
00905                         this.LBLwidths.Visible = this.TXTwidths.Visible;
00906                         this.TXTwidths.Enabled = this.EditMode;
00907                         this.LBLwidths.Enabled = this.TXTwidths.Enabled;
00908 
00909                         this.TXTfooter.Visible = (this.SelectedDynamicMask != null)
00910                                 && (this.SelectedDynamicMask.Type == DynamicMask.DynamicMaskType.ReportMask);
00911                         this.LBLfooter.Visible = this.TXTfooter.Visible;
00912                         this.TXTfooter.Enabled = this.EditMode;
00913                         this.LBLfooter.Enabled = this.TXTfooter.Enabled;
00914 
00915                         this.TXTconsistencyCheckMessage.Visible = 
00916                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck);
00917                         this.LBLconsistencyCheckMessage.Visible = this.TXTconsistencyCheckMessage.Visible;
00918                         this.TXTconsistencyCheckMessage.Enabled = this.TXTconsistencyCheckMessage.Visible && this.EditMode;
00919                         this.LBLconsistencyCheckMessage.Enabled = this.TXTconsistencyCheckMessage.Enabled;
00920                         this.RFVmessage.Enabled = this.TXTconsistencyCheckMessage.Enabled;
00921 
00922                         this.DDLrecordType.Visible =
00923                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck);
00924                         this.LBLrecordType.Visible = this.DDLrecordType.Visible;
00925                         this.DDLrecordType.Enabled = this.EditMode;
00926                         this.LBLrecordType.Enabled = this.DDLrecordType.Enabled;
00927 
00928                         // BUTTONS
00929                         //Add
00930                         this.BTNadd.Text = GetBtnAddText();
00931                         this.BTNadd.Visible = 
00932                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport)
00933                                 || (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport
00934                                 || (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck));
00935                         this.BTNadd.Enabled = !this.EditMode;
00936 
00937                         // Edit
00938                         this.BTNedit.Text = GetBtnEditText();
00939                         this.BTNedit.Enabled = GetEditDeleteEnabled();
00940 
00941                         //Delete
00942                         this.BTNdelete.Text = GetBtnDeleteText();
00943                         this.BTNdelete.Visible = (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport)
00944                                 || (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport
00945                                 || (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck));
00946                         this.BTNdelete.Enabled = GetEditDeleteEnabled();
00947 
00948                         // Apply, Discard
00949                         this.BTNapply.Enabled = this.EditMode;
00950                         this.BTNdiscard.Enabled = this.EditMode;
00951 
00952                         if (this.EditMode)
00953                         {
00954                                 if (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ListWithFilter)
00955                                         this.SetFocus(this.DDLcustomQuery);
00956                         }
00957                         if (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add)
00958                                 this.SetFocus(this.TXTnewMaskName);
00959 
00960                         UI.Common.UserManagement.EnableCommonControls(this, this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.view);
00961                 }
00962 
00963         private bool HideIfEmptyType()
00964         {
00965             bool isEmpty = DDLcustomizationType.SelectedValue == "";
00966 
00967             LBLconsistencyCheck.Visible = !isEmpty;
00968             DDLconsistencyCheck.Visible = !isEmpty;
00969             RFVnewDynamicMaskName.Visible = !isEmpty;
00970             LBLnewDynamicMaskName.Visible = !isEmpty;
00971             TXTnewDynamicMaskName.Visible = !isEmpty;
00972             TXTnewConsistencyCheckName.Visible = !isEmpty;
00973             LBLnewConsistencyCheckName.Visible = !isEmpty;
00974             DDLcategory.Visible = !isEmpty;
00975             LBLcategory.Visible = !isEmpty;
00976             DDLsubcategory.Visible = !isEmpty;
00977             LBLsubcategory.Visible = !isEmpty;
00978             DDLmask.Visible = !isEmpty;
00979             LBLmask.Visible = !isEmpty;
00980             DDLdynamicMask.Visible = !isEmpty;
00981             LBLdynamicMask.Visible = !isEmpty;
00982             TXTnewMaskName.Visible = !isEmpty;
00983             LBLnewMaskName.Visible = !isEmpty;
00984             DDLcustomQuery.Visible = !isEmpty;
00985             LBLcustomQuery.Visible = !isEmpty;
00986             LBLfield.Visible = !isEmpty;
00987             DDLfield.Visible = !isEmpty;
00988             TXTgrouping.Visible = !isEmpty;
00989             LBLgrouping.Visible = !isEmpty;
00990             TXTwidths.Visible = !isEmpty;
00991             LBLwidths.Visible = !isEmpty;
00992             TXTfooter.Visible = !isEmpty;
00993             LBLfooter.Visible = !isEmpty;
00994             TXTconsistencyCheckMessage.Visible = !isEmpty;
00995             LBLconsistencyCheckMessage.Visible = !isEmpty;
00996             DDLrecordType.Visible = !isEmpty;
00997             LBLrecordType.Visible = !isEmpty;
00998 
00999             BTNedit.Visible = !isEmpty;
01000             BTNadd.Visible = !isEmpty;
01001             BTNapply.Enabled = !isEmpty;
01002             BTNdelete.Visible = !isEmpty;
01003             BTNdiscard.Enabled = !isEmpty;
01004 
01005             UI.Common.UserManagement.EnableCommonControls(this, this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.view);
01006             return isEmpty;
01007         }
01011                 private DynamicMask GetDynamicMaskCustomizationParametersFromControls()
01012                 {
01013                         DynamicMask dynamicMask;
01014 
01015                         if (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add)
01016                         {
01017                                 dynamicMask = new DynamicMask();
01018                                 dynamicMask.Name = this.TXTnewDynamicMaskName.Text;
01019                                 dynamicMask.Type = RAIS.Common.DynamicMaskManagement.DynamicMask.DynamicMaskType.ReportMask;
01020                         }
01021                         else
01022                         {
01023                                 dynamicMask = this.SelectedDynamicMask;
01024                         }
01025 
01026                         if (dynamicMask.Type == DynamicMask.DynamicMaskType.ReportMask) 
01027                         {
01028                                 dynamicMask.Grouping = this.TXTgrouping.Text;
01029                                 dynamicMask.Widths = this.TXTwidths.Text;
01030                                 dynamicMask.Footer = this.TXTfooter.Text;
01031                         }
01032 
01033                         return dynamicMask;
01034                 }
01038                 private ConsistencyCheck GetConsistencyCheckCustomizationParametersFromControls()
01039                 {
01040                         ConsistencyCheck consistencyCheck;
01041 
01042                         if (this.CurrentCustomQuery_PageMode == CustomQuery_PageMode.add)
01043                         {
01044                                 consistencyCheck = new ConsistencyCheck();
01045                         }
01046                         else
01047                         {
01048                                 consistencyCheck = this.SelectedConsistencyCheck;
01049                         }
01050 
01051                         if (consistencyCheck != null)
01052                         {
01053                                 consistencyCheck.QueryName = (this.SelectedQuery == null)
01054                                         ? string.Empty
01055                                         : this.SelectedQuery.QueryNameWithParameters;
01056                                 consistencyCheck.Message = this.TXTconsistencyCheckMessage.Text;
01057                                 consistencyCheck.TypeText = this.DDLrecordType.SelectedValue;
01058                         }
01059 
01060                         return consistencyCheck;
01061                 }
01062 
01063                 private string GetBtnAddText()
01064                 {
01065                         string translatedLabelText = string.Empty;
01066                         string labelText = string.Empty;
01067 
01068                         labelText = (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
01069                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
01070                                 ? "Add report"
01071                                 : (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck) 
01072                                         ? "Add consistency check"
01073                                         : "Add";
01074 
01075                         translatedLabelText = RAIS.ApplicationLogicLayer.Localisation.Translate(labelText,
01076                                                                                                                                 this.ToString(),
01077                                                                                                                                 RAIS.Common.Constants.DEFAULT_LANGUAGE,
01078                                                                                                                                 this.CurrentUser.Language);
01079                         return translatedLabelText;
01080                 }
01081 
01082                 private string GetBtnEditText()
01083                 {
01084                         string translatedLabelText = string.Empty;
01085                         string labelText = string.Empty;
01086 
01087                         labelText = (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
01088                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
01089                                 ? "Edit report"
01090                                 : (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
01091                                         ? "Edit consistency check"
01092                                         : "Select custom query";
01093 
01094                         translatedLabelText = RAIS.ApplicationLogicLayer.Localisation.Translate(labelText,
01095                                                                                                                                 this.ToString(),
01096                                                                                                                                 RAIS.Common.Constants.DEFAULT_LANGUAGE,
01097                                                                                                                                 this.CurrentUser.Language);
01098                         return translatedLabelText;
01099                 }
01100 
01101                 private string GetBtnDeleteText()
01102                 {
01103                         string translatedLabelText = string.Empty;
01104                         string labelText = string.Empty;
01105 
01106                         labelText = (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
01107                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
01108                                 ? "Delete report"
01109                                 : (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
01110                                         ? "Remove Consistency check"
01111                                         : "Delete";
01112 
01113                         translatedLabelText = RAIS.ApplicationLogicLayer.Localisation.Translate(labelText,
01114                                                                                                                                 this.ToString(),
01115                                                                                                                                 RAIS.Common.Constants.DEFAULT_LANGUAGE,
01116                                                                                                                                 this.CurrentUser.Language);
01117                         return translatedLabelText;
01118                 }
01119 
01120                 private string GetDeleteQuestion()
01121                 {
01122                         string text = string.Empty;
01123 
01124                         text = (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport
01125                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
01126                                 ? RAIS.Common.Messages.DELETE_QUESTION_REPORT
01127                                 : (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
01128                                         ? RAIS.Common.Messages.DELETE_QUESTION_CONSISTENCY_CHECK
01129                                         : RAIS.Common.Messages.DELETE_QUESTION_RECORD;
01130 
01131                         return RAIS.ApplicationLogicLayer.Localisation.Translate(text,
01132                                                                                                                                 this.ToString(),
01133                                                                                                                                 RAIS.Common.Constants.DEFAULT_LANGUAGE,
01134                                                                                                                                 this.CurrentUser.Language);
01135                 }
01136 
01137                 private bool GetEditDeleteEnabled()
01138                 {
01139                         bool enabled = !this.EditMode 
01140                                 && 
01141                                 (
01142                                         (
01143                                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ListWithFilter)
01144                                                 || 
01145                                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.QueryReport)
01146                                                 || 
01147                                                 (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.StatisticsReport)
01148                                         ) && this.SelectedDynamicMask != null
01149                                         ||
01150                                         (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.ConsistencyCheck)
01151                                                 && this.SelectedConsistencyCheck != null
01152                                         ||
01153                                         (this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.EntryFilter
01154                                                 || this.SelectedCustomizationType == RAIS.Common.TableManagement.Query.CustomizationType.RanAutogeneration
01155                                         )
01156                                                 && this.SelectedField != null
01157                                 );
01158 
01159                         return enabled;
01160                 }
01161                 #endregion
01162         }
01163 }